var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0}), (o.Hutuiqiang = void 0);
var a = t("Platforms"),
    i = t("Const"),
    s = t("Sounds"),
    c = t("CPBIcon"),
    l = t("Popup"),
    u = t("ConfS"),
    p = cc._decorator,
    f = p.ccclass,
    d =
        (p.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            return (
                n(e, t),
                (e.prototype.init = function () {
                    var t = this,
                        e = this.node.getChildByName("container");
                    (this.icons = e.getChildByName("scrollView").getChildByName("view").getChildByName("icons")),
                        (this.close = e.getChildByName("close")),
                        this.close.on(cc.Node.EventType.TOUCH_END, function () {
                            s.Sounds.playFX("点击"), t.hide();
                        }),
                        i.default.wid0 > i.default.hei0 ||
                            ((e.width = 640), (e.height = i.default.shei - 200), (e.y = -i.default.shei / 2 + 150));
                }),
                (e.prototype.show = function () {
                    var e;
                    t.prototype.show.call(this), (e = i.default.wid0 > i.default.hei0 ? 2 : 1);
                    for (
                        var o = -1, n = new Array(), r = -1, s = 0, l = 0, p = a.default.platformCtrl.cpbConfig.cpbs;
                        l < p.length;
                        l++
                    ) {
                        var f = p[l];
                        o++, ++r >= e && ((r = 0), s++);
                        var d = a.default.prefabs.instantiate("CPBIcon2").getComponent(c.default);
                        this.icons.addChild(d.node),
                            n.push(d),
                            (d.node.x = 480 * r),
                            (d.node.y = -142 * s),
                            d.init(o, !1, !1, !1, function (t, e, o) {
                                o
                                    ? ((a.default.platformCtrl.hutuiStartTime = new Date().getTime()),
                                      console.log("hutuiStartTime=" + a.default.platformCtrl.hutuiStartTime),
                                      (a.default.platformCtrl.onHutuiCallback = function (o) {
                                          a.default.userStorage.当天试玩过的游戏appId们.indexOf(e.appId) > -1
                                              ? a.default.delays.delay({
                                                    time: 0.5,
                                                    action: function () {
                                                        a.default.platformCtrl.toast("您已领取过奖励！");
                                                    }
                                                })
                                              : o
                                              ? (a.default.grey(t.node.getChildByName("btn").getComponent(cc.Sprite)),
                                                (t.yilingqu.active = !0),
                                                a.default.userStorage.当天试玩过的游戏appId们.push(e.appId),
                                                a.default.userStorage.setDirty(),
                                                a.default.delays.delay({
                                                    time: 0.5,
                                                    action: function () {
                                                        i.default.addMoney(
                                                            u.DatasManager.试玩奖励货币,
                                                            u.DatasManager.试玩奖励货币数量,
                                                            "试玩领奖",
                                                            t.node.getChildByName("btn"),
                                                            null
                                                        ),
                                                            a.default.userStorage.setDirty();
                                                    }
                                                }))
                                              : a.default.delays.delay({
                                                    time: 0.5,
                                                    action: function () {
                                                        a.default.platformCtrl.toast("未体验15秒，无法领取奖励！");
                                                    }
                                                });
                                      }),
                                      "调试" == a.default.platformType &&
                                          (a.default.platformCtrl.onHutuiCallback(!0),
                                          (a.default.platformCtrl.onHutuiCallback = null)))
                                    : a.default.platformCtrl.toast("跳转小游戏失败");
                            }),
                            (d.rewardtxt.string = "x" + u.DatasManager.试玩奖励货币数量),
                            a.default.userStorage.当天试玩过的游戏appId们.indexOf(f.appId) > -1
                                ? (a.default.grey(d.node.getChildByName("btn").getComponent(cc.Sprite)),
                                  (d.yilingqu.active = !0))
                                : (d.yilingqu.active = !1);
                    }
                    this.icons.height = 142 * (s + 1);
                    for (var h = 0, y = n; h < y.length; h++) {
                        (d = y[h]).node.removeChild(d.img.node, !1),
                            this.icons.addChild(d.img.node),
                            (d.img.node.x += d.node.x),
                            (d.img.node.y += d.node.y),
                            d.node.removeChild(d.nameTxt.node, !1),
                            this.icons.addChild(d.nameTxt.node),
                            (d.nameTxt.node.x += d.node.x),
                            (d.nameTxt.node.y += d.node.y);
                    }
                }),
                (e.prototype.showComplete = function () {
                    t.prototype.showComplete.call(this);
                }),
                (e.prototype.hide = function () {
                    t.prototype.hide.call(this);
                }),
                (e.prototype.hideComplete = function () {
                    t.prototype.hideComplete.call(this), this.icons.destroyAllChildren();
                }),
                (e = r([f], e))
            );
        })(l.Popup));
o.Hutuiqiang = d;
